<template>
    <div>
        <i-form v-if="app.checkPermission('Workflow.ManageAllWorkflow')">
            <i-form-item label="执行人">
                <user-selector v-model="targetUserId" />
            </i-form-item>
            <i-form-item label="执行步骤">
                <i-input v-model="nextStep" />
            </i-form-item>
            <i-form-item>
                <i-button type="primary" @click="gotoStep">确认</i-button>
            </i-form-item>
        </i-form>
    </div>
</template>

<script>
const axios = require("axios");
const app = require("@/config");
export default {
    data () {
        return {
            app,
            targetUserId: "",
            nextStep: "",
            instanceId: "",
            stepId: ""
        }
    },
    mounted () {
        this.instanceId = this.$route.query.instanceId;
        this.stepId = this.$route.query.stepId;
        this.getFields();
    },
    methods: {
        gotoStep () {
            axios.post("/api/workflow/GotoStep", {instanceId: this.instanceId, stepId: this.stepId, userId: this.targetUserId, nextStep: this.nextStep}, msg => {
                if (msg.success) {
                    this.form = msg;
                    this.$Message.success("强制执行步骤成功");
                } else {
                    this.$Message.warning(msg.msg);
                }
            })
        },
        getFields () {
            axios.post("/api/workflow/LoadInstance", {instanceId: this.instanceId, stepId: this.stepId, detail: true}, msg => {});
        }
    }
}
</script>

<style>

</style>
